package com.xiongwei.thread;

/**
 * Thread的状态包括:New,Runnable,Blocked,Waiting,Timed Waiting,Terminated;
 * 线程启动后,可以在Runnable,Blocked,Waiting,Timed Waiting这几个状态之间切换
 *
 * 通过对另一线程对象调用join方法,可以等待其执行结束(相当于插队);
 * 对于指定等待时间,超过等待时间线程仍然没有结束就不再等待;
 * 对已经运行结束的线程调用join方法会立刻返回.
 *
 * @author XiongWei
 * @date 2021/1/13
 */
public class ThreadState {

    public static void main(String[] args) throws InterruptedException {
        Thread t = new Thread(() -> System.out.println("t join"));
        System.out.println("main first");
        t.start();
        t.join();
        System.out.println("main end after t join forever");
    }
}
